package com.xaptul.docpreview.util.converter;

import java.util.HashMap;

import org.apache.commons.io.FilenameUtils;

import com.xaptul.docpreview.util.abstra.Converter;

public class ConverterMap extends HashMap<String, Converter> {
	private static final long serialVersionUID = -6485148081285809528L;

	public ConverterMap(Converter[] converters) {
		for (Converter converter : converters)
			for (String epr : ((Supported) converter.getClass().getAnnotation(
					Supported.class)).value())
				put(epr.substring(2), converter);
	}

	public Converter getByFilename(String filename) {
		return (Converter) get(FilenameUtils.getExtension(filename));
	}
}